﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace TotalSport
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["TotalSport"].ConnectionString;
        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            clear();
        }
        public void clear()
        {
            txtNewPassword.Text = "";
            txtOldPassword.Text = "";
            txtReNewPassword.Text = "";
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            int UserId = Convert.ToInt16(Session["UserId"].ToString());
            string oldpas = txtOldPassword.Text;
            string newpas = txtNewPassword.Text;
            
            string stropas = BAL.Encryption.Encript(oldpas, "&%#@?,:*");
            string strnpas = BAL.Encryption.Encript(newpas, "&%#@?,:*");
            int val = BAL.Customers.ChangePasswordDetails(stropas,strnpas,UserId);

            if (val == -1)
            {
                SMessage.Style.Add("Display", "block");
                SMessage.InnerHtml = "Sorry,password not match to old pass";
            }
            else
            {
                
                Response.Redirect("~/LoginUser.aspx");

            }




        }


    }
}